﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace HRP.Private.Profile
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //check if current pass is ok

            var dadosLogin = Cliente_BLL.Instance.loginClient(Session["user"].ToString(), currentPasswordTB.Text.ToString());
          
            if (dadosLogin != null)
            {
                if (newPasswordTB.Text == newPassword2TB.Text)
                {
                    Cliente_BLL.Instance.updatePassword(Convert.ToInt32(Session["userid"]), newPasswordTB.Text.ToString());
                    messageLB.Text = "Alterado.";
                }
                else { messageLB.Text = "Novas senhas não coincidem"; return; }
            }
            else
            {
                messageLB.Text = "Password actual invalida.";
                return;
            }

        }
    }
}